﻿using Microsoft.AspNet.Identity.EntityFramework;
using NewsPortal.Domain;
using NewsPortal.Domain.Layout;
using NewsPortal.Domain.PostEntities;
using NewsPortal.Domain.User;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Reflection;

namespace NewsPortal.DataAccess
{
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext() : base("DefaultConnection") { }
        public DbSet<Page> Pages { get; set; }
        public DbSet<Grid> Grids { get; set; }
        public DbSet<Row> Rows { get; set; }
        public DbSet<Column> Columns { get; set; }
        public DbSet<Post> Posts { get; set; }
        public DbSet<PostCategory> PostCategories { get; set; }
        public DbSet<Tag> Tags { get; set; }
        public DbSet<Comment> Comments { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.AddFromAssembly(Assembly.GetExecutingAssembly());
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            base.OnModelCreating(modelBuilder);
        }
    }
}
